import Shape2D from "./Shape2D";
import Point2D from "../Point/Point2D";

export default class Rect extends Shape2D {
    /**
     *
     * @param centre    {Point2D=}
     * @param width     {number=}
     * @param height    {number=}
     * @param angle     {number=}
     */
    constructor(centre = new Point2D(0, 0), width, height, angle = 0) {
        super(centre, angle);
        this.width = width;
        this.height = height;
    }

    // overwrite
    getHornPoints() {
        let hornPoints = [];
        let halfWidth = this.width / 2;
        let halfHeight = this.height / 2;
        for (let edge = 1; edge <= 4; edge++) {
            switch (edge) {
                case 1:
                    hornPoints.push(new Point2D(this.centre.x - halfWidth, this.centre.y - halfHeight));
                    break;
                case 2:
                    hornPoints.push(new Point2D(this.centre.x + halfWidth, this.centre.y - halfHeight));
                    break;
                case 3:
                    hornPoints.push(new Point2D(this.centre.x + halfWidth, this.centre.y + halfHeight));
                    break;
                case 4:
                    hornPoints.push(new Point2D(this.centre.x - halfWidth, this.centre.y + halfHeight));
                    break;
                default:
            }
        }
        return hornPoints;
    }
}